From 903be77ae802f0db84d128e6ec5a9cfd42517108 Mon Sep 17 00:00:00 2001 From: Evgen Druzhynin Date: Sat, 27 May 2017 12:33:12 +0300 Subject: [PATCH] Remove warnings about old configuration on publish. --- src/cargo/ops/registry.rs | 8 -------- src/cargo/util/config.rs | 28 ---------------------------- tests/publish.rs | 4 ++-- 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 7bf9a0f08..78681a690 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -66,14 +66,6 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> { opts.config.shell().status("Uploading", pkg.package_id().to_string())?; transmit(opts.config, pkg, tarball.file(), &mut registry, opts.dry_run)?; - if opts.config.is_token_in_main_config() { - let _ = opts.config - .shell() - .warn("API token detected in ~/.cargo/config under `registry.token`.\n \ - You should remove it and do `login` again in order to \ - save token in ~/.cargo/credentials"); - } - Ok(()) } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index c99ec82c6..b99285ce7 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -34,10 +34,6 @@ pub struct Config { extra_verbose: Cell, frozen: Cell, locked: Cell, - - // A temporary solution to point on an old configuration's usage. - // If it's true cargo will warn on it on publish. - token_in_main_config: Cell, } impl Config { @@ -55,7 +51,6 @@ impl Config { extra_verbose: Cell::new(false), frozen: Cell::new(false), locked: Cell::new(false), - token_in_main_config: Cell::new(false), } } @@ -408,10 +403,6 @@ impl Config { !self.frozen.get() && !self.locked.get() } - pub fn is_token_in_main_config(&self) -> bool { - self.token_in_main_config.get() - } - pub fn load_values(&self) -> CargoResult> { let mut cfg = CV::Table(HashMap::new(), PathBuf::from(".")); @@ -438,8 +429,6 @@ impl Config { Ok(()) }).chain_err(|| "Couldn't load Cargo configuration")?; - self.token_in_main_config.set(check_token_in_main_config("registry.token".into(), &cfg)); - let mut map = match cfg { CV::Table(map, _) => map, _ => unreachable!(), @@ -823,20 +812,3 @@ fn load_credentials(home: &PathBuf) -> CargoResult> { Ok(Some(token.trim().into())) } - -fn check_token_in_main_config(key: &str, cfg: &ConfigValue) -> bool { - let mut keys = key.split('.'); - let k = keys.next().unwrap(); - let keys: String = keys.map(String::from).collect(); - - match *cfg { - CV::Table(ref map, _) => { - match map.get(k) { - Some(ref v) => check_token_in_main_config(keys.as_str(), v), - None => return false, - } - } - CV::String(ref v, _) => !v.is_empty(), - _ => return false, - } -} diff --git a/tests/publish.rs b/tests/publish.rs index f514adf9c..968281f62 100644 --- a/tests/publish.rs +++ b/tests/publish.rs @@ -57,7 +57,7 @@ fn simple() { assert_that(p.cargo_process("publish").arg("--no-verify") .arg("--host").arg(registry().to_string()), - execs().with_status(0).with_stderr_contains(&format!("\ + execs().with_status(0).with_stderr(&format!("\ [UPDATING] registry `{reg}` [WARNING] manifest has no documentation, [..] See [..] @@ -371,7 +371,7 @@ fn dry_run() { assert_that(p.cargo_process("publish").arg("--dry-run") .arg("--host").arg(registry().to_string()), - execs().with_status(0).with_stderr_contains(&format!("\ + execs().with_status(0).with_stderr(&format!("\ [UPDATING] registry `[..]` [WARNING] manifest has no documentation, [..] See [..] -- 2.30.2